#CC = arm-himix200-linux-gcc
CC = gcc
CFLAGS = -Wall -Wextra -g
LDFLAGS =

SRCDIR = .
BINDIR = .

# Source files
SERVER_SRCS = $(SRCDIR)/write.c
RINGFIFO_SRCS = $(wildcard $(SRCDIR)/ringfifo/*.c)

# Object files
SERVER_OBJS = $(SERVER_SRCS:.c=.o)
RINGFIFO_OBJS = $(RINGFIFO_SRCS:.c=.o)

# Target
TARGET = $(BINDIR)/rtsp_server

# Build rules
.PHONY: all clean

all: $(TARGET)

$(TARGET): $(SERVER_OBJS) $(RINGFIFO_OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -pthread -lrt

$(SERVER_SRCS:.c=.o): $(SERVER_SRCS)
	$(CC) $(CFLAGS) -c $< -o $@ -I./ringfifo

$(RINGFIFO_SRCS:.c=.o): $(RINGFIFO_SRCS)
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	$(RM) $(TARGET) $(SERVER_OBJS) $(RINGFIFO_OBJS)
